package sample.getvalue;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTextField;

public class GetGUIValue {

	public void foo() {
		JButton b = new JButton("Button-Text-1");
		String s = b.getText();
		System.out.println(s);
		JButton b2 = new JButton("Button-Text-2");
		bar(b2);
		//call moo
		moo();
	}
	
	public void bar(JButton b) {
		String s = b.getText();
		System.out.println(s);
	}
	
	public void moo() {
		final JTextField jtextfield = new JTextField("N/A", 3);
		String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
		final JComboBox petList = new JComboBox(petStrings);
		petList.setSelectedIndex(4);
		boo(jtextfield, petList);
	}
	
	public void boo(JTextField tf, JComboBox cb) {
		System.out.println(tf.getText());
		System.out.println(cb.getSelectedItem());
	}
	
	public static void main(String[] args) {
		new GetGUIValue().foo();
	}
	
}
